<template>
    <div>
        <van-field v-model="phone" required clearable name="phone" label="手机号" />
        <van-field v-model="mail" required clearable name="mail" label="邮箱" />
        <!--<van-field type="password" v-model="password" required clearable name="pawword" label="密码" />
        <van-field type="password" v-model="repasswd" required clearable name="repasswd" label="确认密码" />-->
        <van-button :disabled="change_success" type="info" size="large" style="margin-top:5vh;" @click="modifyInfo">{{ modify_text }}</van-button>
    </div>
</template>

<script>
    import Vue from 'vue'
    import { Cell, PullRefresh, Toast, Tabbar, TabbarItem, Popup, Col, Row } from 'vant'
    import qs from 'qs'
    Vue.use(Cell).use(PullRefresh).use(Toast).use(Tabbar).use(TabbarItem).use(Popup).use(Col).use(Row)

    export default {
        name: 'forgetpwd',
        data () {
            return {
                change_success: false,
                modify_text: '提交',

                phone: '',
                mail: ''
            }
        },
created: function () {
            let data = {}
            this.axios({
                method: 'post',
                url: '/api/employee.updategetinfo.do',
                data: qs.stringify(data)
            }).then(res => {
                //console.log(res)
                this.phone = res.data.phone
                this.mail = res.data.mail
            }).catch(res => {
                this.reserror(res)
            })
        },
        methods: {
            modifyInfo: function () {
                let data = {
                    mobile: this.phone,
                    mail: this.mail
                }
                this.change_success = true
                this.axios({
                    method: 'post',
                    url: '/api/employee.updatemobile.do',
                    data: qs.stringify(data)
                }).then(res => {
                    // //console.log(res)
                    if (res.data.code === 200) {
                        this.modify_text = '修改成功，3s后返回上页'
                            setTimeout(() => {
                                this.$router.go(-1)
                            }, 3000)
                    } else {
                        this.modify_text = '修改失败，请联系工作人员'
                            setTimeout(() => {
                                this.$router.go(-1)
                            }, 3000)
                    }
                })
            }
        }
    }
</script>
